home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
By the Book
/
Learn C++ (CodeWarrior)
/
Chap 07.04 - call
/
call.cp
< prev
next >
Wrap
Text File
|
1995-10-26
|
1KB
|
47 lines
#include <iostream.h>
//--------------------------------------- Item
class Item
{
private:
float price;
public:
Item( float itemPrice );
// Note that the default value for taxRate has been removed. The book
// uses a default value of 0. As it turns out, section 13,5 of
// the ANSI C++ draft states that an operator function cannot have
// default arguments. This faulty code compiled under THIN C++ but
// was tripped up by the CodeWarrior compiler.
//
// In this version, I just removed the default value for taxRate
// and changed the call stimpyDoll() to stimpyDoll( 0 ) to
// achieve the same result. Thanks to Khurram Quereshi for figuring
// this one out!! -- Dave Mark, 10/26/95
float operator()( float taxRate );
};
Item::Item( float itemPrice )
{
price = itemPrice;
}
float Item::operator()( float taxRate )
{
return( ((taxRate * .01) + 1) * price );
}
//--------------------------------------- main()
int main()
{
Item stimpyDoll( 36.99 );
cout << "Price of Stimpy doll: $" << stimpyDoll( 0 );
cout << "\nPrice with 4.5% tax: $" << stimpyDoll( 4.5 );
return 0;
}